package com.gi.profiler;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.gi.profiler.controllers.ProfileController;
import com.gi.profiler.listeners.ProfileListListener;
import com.gi.profiler.model.Profile;
import com.gi.profiler.providers.ProfileListAdapter;

public class ProfileListActivity extends Activity {

    private ListView lstProfiles;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.profile_list);

	ArrayAdapter<Profile> adapter = new ProfileListAdapter(this, R.layout.profile_list_item,
		new ProfileController().getProfileList());

	lstProfiles = (ListView) findViewById(R.id.lst_profiles);

	addHeader();
	lstProfiles.setAdapter(adapter);
	lstProfiles.setOnItemClickListener(new ProfileListListener(this));

    }
    
    private void addHeader(){
	View header = (View) getLayoutInflater().inflate(R.layout.list_title, null);
	((TextView) header.findViewById(R.id.txt_header)).setText(R.string.title_lst_profile);
	lstProfiles.addHeaderView(header);
    }
}
